Skip to content

Conversation

@rahulrajaram
Copy link
Contributor

@rahulrajaram rahulrajaram commented Apr 22, 2019

1. Overview

This PR:

  • enhances the existing Windows Python installer script
  • introduces bundled installers for PowerShell and BAT

Refer to the independent commit messages for precise details.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.


2. Installation Prerequisites

  • git
  • Powershell/CMD Prompt on Windows

3. Testing:

Follow installation instructions laid out here.

3.1. bundled_installer:

  • invokes Python installer for PowerShell (install-python.ps1) regardless of whether Python is in PATH or not
  • terminates immediately with a non-0 exit code if Python installer for PowerShell fails; it does not invoke the EBCLI installer
  • invokes the EBCLI installer regardless of whether eb has been installed through this means or any other at a prior point if the Python installer returns normally.

3.2. install-python.ps1:

  • skips Python 3.7.3 installation if Python 3.7.3 is found in PATH
  • installs Python 3.7.3 if any Python other than 3.7.3 is found in PATH
  • installs Python 3.7.3 if no Python is found in PATH
  • installs virtualenv if Python installation succeeds or is skipped
  • installs virtualenv even if it is already in PATH
  • does not install virtualenv if Python installation fails
  • Python installation fails if the MSI cannot be downloaded from Python's website (mangle the URL to test this).
  • Python installation fails if the MSI is exited by the user
  • After Python installation succeeds, PATH is updated such that python is in the current PowerShell session.
  • After Python installation succeeds, PATH is updated such that python is present in the current PowerShell session and the future sessions.

3.3. ebcli_installer.py:

Refer to the steps here.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

The choice of bitness depends on the bitness of the OS and 32-bit
OSes can run on 64-bit architecture so the check for OS-bitness
is more accurate.
The proposed name clarifies what the variable is better.
Originally, opening up a new PowerShell session solved the problem of
changes to $env:PATH not taking effect in the current session. However,
this can be solved by updating the current session's PATH variable.

`Cleanup` is no longer necessary, so the only remaining statement (to
remove the downloaded Python MSI) is extracted out. Additionally, this
step is performed only if the Python MSI was downloaded.
Installing in the background might obfuscate errors during installation.
Through this change, the user will be prompted to click through the MSI
GUI.
Although the Python MSI adds Python to PATH, the change will only take
effect in a new session. This change adds Python to the current session
so that the user does not have to close their terminal.
@rahulrajaram rahulrajaram requested a review from jsheld April 22, 2019 07:53
Update-UserEnvironmentPath
Remove-Item $PythonInstaller
} else {
Write-Host "Python 3.7.3 is already installed. Exiting." -ForegroundColor Green
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

" Exiting." is redundant.

function Download-Python {
$url = Get-PythonInstallationTarget
$client = New-Object System.Net.WebClient
$client.DownloadFile($url, $PythonInstaller)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this fails, returning $True doesn't make sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is eliminate in a future commit.

…value

Rename: "Get" is a PowerShell-approved verb, whereas "Assert" is not.

This change also modifies the return contract of `Get-PythonExecutable`
such that it returns the Python 3.7.3 executables found rather than the
indication of whether a Python 3.7.3 executable exists.
When the user exits from the Python MSI prematurely, it returns the exit
code 1602.
The PS1 script invokes:
- install-python.ps1
- ebcli_installer.py if the Python installer exists with code 0

The PS1 script installs instructs ebcli_installer.py to install `eb` in
the user's home directory (within a .ebcli-virtual-env folder).

The BAT script wraps the PS1 script.
Future steps may rely on the existence of Python. If Python installation
fails, subsequent statements will fail. To preclude subsequent failures,
the script will exit immediately following failure to install.
@rahulrajaram rahulrajaram merged commit ebf048b into master May 1, 2019
@rahulrajaram rahulrajaram deleted the PowershellChanges branch May 1, 2019 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants